﻿using WebAndLoadTestPluginsAndRules;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace HtmlTagInnerTextTests
{
    
    
    /// <summary>
    ///This is a test class for SelectTagParserTest and is intended
    ///to contain all SelectTagParserTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SelectTagParserTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            PageManager.Initialize(testContext);
        }
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetAllSelectedOptions
        ///</summary>
        [DeploymentItem("webtestrulestests\\testpages\\testpage.htm"), TestMethod()]
        public void GetAllSelectedOptionsTest()
        {
            string documentContent;
            PageManager.Instance.LoadPage("TestPage.htm", out documentContent);
            //PageManager.Instance.LoadPage("..\\..\\..\\HtmlTagInnerTextTests\\TestPages\\TestPage.htm", out documentContent);

            SelectTagParser selectParser = new SelectTagParser(documentContent);

            foreach (string option in selectParser.GetAllSelectedOptions("myselect1"))
            {
                Assert.AreEqual("Tea", option);
            }

            foreach (string option in selectParser.GetAllSelectedOptions("003"))
            {
                Assert.AreEqual("Dog", option);
            }

            List<string> options = new List<string>();
            foreach (string option in selectParser.GetAllSelectedOptions(null))
            {
                options.Add(option);
            }
            Assert.AreEqual(2, options.Count);
            Assert.AreEqual("Tea", options[0]);
            Assert.AreEqual("Dog", options[1]);
        }
    }
}
